﻿using Integration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Integration.Tests
{
    [TestClass()]
    public class CsvSerializerTest
    {
        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        public class TestObject
        {
            public int Id { get; set; }

            public DateTime Date { get; set; }

            public string Name { get; set; }

            public string Comments { get; set; }
        }


        [TestMethod()]
        public void CsvSerializerSerializeTest()
        {
            TestObject testObject = new TestObject
            {
                Id = 111,
                Date = new DateTime(2005, 5, 25, 2, 23, 34),
                Name = "Doe, Joe",
                Comments =
@"Sent an email: return email - he wrote ""Thanks.  Will let you know.""
(Recorded 07/12/2008 12:12 pm)"
            };


            CsvSerializer<TestObject> serializer = new CsvSerializer<TestObject>();

            string row = serializer.Serialize(testObject);

            Assert.AreEqual(
@"111,5/25/2005 2:23:34 AM,""Doe, Joe"",""Sent an email: return email - he wrote """"Thanks.  Will let you know.""""
(Recorded 07/12/2008 12:12 pm)""", row);

        }
    }
}
